/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.graphicals;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

/**
 *
 * @author laetitia
 */
public class RightClickPopupMenu extends JPopupMenu {
    
    
    public RightClickPopupMenu() {
        System.out.println("Menu clique droit !");
    }
    
    public JMenuItem addItemToMenu(String menuItemName, String iconName, ActionListener actionListener) {
        
        JMenuItem menuItem;
        
        add(menuItem = new JMenuItem());
        
        menuItem.setText(menuItemName);
        menuItem.setActionCommand(menuItemName);
        
        if (!iconName.equals("")) {
            
            URL imagePath = getClass().getResource("/drawable/" + iconName);
            if (imagePath != null) {
                menuItem.setIcon(new ImageIcon(imagePath, iconName));
            }
                
        }
        menuItem.addActionListener(actionListener);
        
        return menuItem;
    }
    
}
